using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Hand : MonoBehaviour
{
    public bool isLeft;
    public SpriteRenderer spriter;
    private SpriteRenderer player;
    Vector3 rightPos = new Vector3(0.31f, -0.09f, 0);
    Vector3 rightPosReverse = new Vector3(-0.31f, -0.09f, 0);
    Vector3 LeftPos = new Vector3(-0.19f, -0.33f, 0);
    Vector3 LeftPosReverse = new Vector3(0.19f, -0.33f, 0);
    Quaternion leftRot = Quaternion.Euler(0, 0, -23.85f);
    Quaternion leftRotReverse = Quaternion.Euler(0, 0, 23.85f);

    private void Awake()
    {
        player = GetComponentsInParent<SpriteRenderer>()[1];
    }
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        bool isReverse = player.flipX;
        if (isLeft)
        {
            transform.localPosition = isReverse ? LeftPosReverse : LeftPos;
            transform.localRotation = isReverse ? leftRotReverse : leftRot;
            spriter.flipX = isReverse;
            //spriter.sortingOrder = isReverse ? -1 : 1;
        }
        else
        {
            transform.localPosition = isReverse ? rightPosReverse : rightPos;
            spriter.flipX = isReverse;
            //spriter.sortingOrder = isReverse ? 1 : -1;

        }
    }
}
